FLAGS = -lglfw -lopengl32 -lglu32 -lfreetype -lcorona
SERVER_FLAGS = -lws2_32 -lsqlite3x -lsqlite3-dll

SERVER_OBJECTS = socket.o database.o client.o
GAME_OBJECTS = game.o font.o gui.o button.o component.o guiclass.o container.o listener.o textcomp.o textline.o image.o scrollbar.o logingui.o textarea.o imagebutton.o scrollpanel.o chatgui.o bar.o togglebtn.o hovertxt.o clist.o
OBJ = $(SERVER_OBJECTS) $(GAME_OBJECTS)

GAME_BIN = game.exe
SERVER_BIN = server.exe

CC = g++

# Game Build 

game.exe: $(GAME_OBJECTS)
	$(CC) -o $(GAME_BIN) $(GAME_OBJECTS) $(FLAGS)
	
game.o: game.cpp game.h image.o scrollbar.o
	$(CC) -c game.cpp

gui.o: gui.cpp gui.h guiconstants.h button.o component.o listener.o
	$(CC) -c gui.cpp

imagebutton.o: imgbtn.cpp imgbtn.h guiconstants.h
	$(CC) -o $@ -c $<
	
listener.o: listener.cpp listener.h guiconstants.h
	$(CC) -c listener.cpp 

scrollpanel.o: scrollpanel.cpp scrollpanel.h guiconstants.h
	$(CC) -c $<

button.o: button.cpp button.h guiconstants.h
	$(CC) -c button.cpp
	
togglebtn.o: togglebtn.cpp togglebtn.h guiconstants.h button.cpp button.h
	$(CC) -c togglebtn.cpp
	
image.o: image.h image.cpp
	$(CC) -c image.cpp

component.o: component.cpp component.h guiconstants.h
	$(CC) -c component.cpp

bar.o: bar.cpp bar.h guiconstants.h
	$(CC) -c $<

hovertxt.o: hovertext.cpp hovertext.h guiconstants.h
	$(CC) -o $@ -c $<

scrollbar.o: scrollbar.cpp scrollbar.h guiconstants.h
	$(CC) -c scrollbar.cpp

textcomp.o: textcomp.cpp textcomp.h guiconstants.h
	$(CC) -c textcomp.cpp
	
textline.o: textline.cpp textline.h guiconstants.h textcomp.h
	$(CC) -c textline.cpp
	
textarea.o: textarea.cpp textarea.h textcomp.h guiconstants.h
	$(CC) -c textarea.cpp

container.o: container.cpp container.h guiconstants.h
	$(CC) -c container.cpp

clist.o: clist.cpp clist.h container.h container.cpp guiconstants.h
	$(CC) -c $<

guiclass.o: guiclass.cpp guiclass.h guiconstants.h
	$(CC) -c guiclass.cpp
	
logingui.o: logingui.cpp logingui.h guiconstants.h
	$(CC) -c logingui.cpp

chatgui.o: chatgui.cpp chatgui.h guiconstants.h
	$(CC) -c chatgui.cpp

font.o: font.cpp font.h
	$(CC) -c font.cpp

# Server Build 
	
server: server.cpp $(SERVER_OBJECTS) 
	$(CC) -o $(SERVER_BIN) $^ $(SERVER_FLAGS)
	$(CC) -o console.exe console.cpp socket.o -lws2_32

socket.o: socket.cpp socket.h
	$(CC) -c $<

database.o: database.cpp database.h
	$(CC) -c $<

client.o: client.cpp client.h
	$(CC) -c $<


# Clean Routine

clean-server:
	rm $(SERVER_OBJECTS)
	
clean-game:
	rm $(GAME_OBJECTS)

clean:
	rm $(OBJ)

real-clean: clean
	rm $(GAME_BIN) $(SERVER_BIN)
